package com.lagou.sortdata;

import javafx.scene.control.TableRow;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.logging.log4j.core.appender.FileManager;

import java.io.IOException;

public class FileDataDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //获取conf和job实例
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "FileDataDriver");
        //设置相关类class
        job.setJarByClass(FileDataDriver.class);

        job.setMapperClass(FileDataMapper.class);
        job.setReducerClass(FileDataReducer.class);

        job.setMapOutputKeyClass(LongWritable.class);
        job.setMapOutputValueClass(LongWritable.class);

        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(LongWritable.class);

        //指定输入，输出路径,该路径包含file1 file2 file3
        FileInputFormat.setInputPaths(job,new Path("E:\\wkproject\\mode1\\mrwork_input"));
        FileOutputFormat.setOutputPath(job,new Path("E:\\wkproject\\mode1\\outfile"));
        //工作提交
        boolean result = job.waitForCompletion(true);
        System.exit(result? 0:1);
    }
}
